package net.hn.hnms.biz.mine.controller;

import cn.dev33.satoken.annotation.SaCheckPermission;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import net.hn.hnms.biz.mine.domain.MineConfig;
import net.hn.hnms.biz.mine.domain.vo.SafetyDayVo;
import net.hn.hnms.biz.mine.service.IMineConfigService;
import net.hn.hnms.sys.common.core.domain.R;
import net.hn.hnms.sys.common.core.web.controller.BaseController;
import net.hn.hnms.sys.common.satoken.config.AutoSetMineCode;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.List;


@RestController
@RequestMapping("config/mine")
@Api(value = "矿井安全信息配置控制器", tags = {"矿井安全信息配置"})
public class MineConfigController extends BaseController {

    @Resource
    private IMineConfigService mineConfigService;


    /**
     * 修改其他生产计划
     */
    @ApiOperation("修改配置")
    @SaCheckPermission("config:mine:update")
    @PutMapping("/update")
    public R<Void> update(@Validated @RequestBody MineConfig mineConfig) {
        mineConfigService.updateById(mineConfig);
        return R.ok();
    }

    /**
     * 获取重点工作执行
     */
    @ApiOperation("获取列表")
    @GetMapping("/page")
    @AutoSetMineCode
    public R<List<MineConfig>> page() {
        return R.ok(mineConfigService.list());
    }

    @ApiOperation("获取安全生产天数")
    @GetMapping("/safetyDays")
    @AutoSetMineCode
    public R<SafetyDayVo> safetyDays(@ApiParam(value = "煤矿编码") String mineCode) {
        return R.ok(mineConfigService.getSafetyDays(mineCode));
    }

}
